﻿<%@ Control Language="C#" AutoEventWireup="true" CodeFile="ViewMessages.ascx.cs" Inherits="UserControl_ViewMessages" %>
<style type="text/css">
    .style8
    {
        height: 21px;
    }
    .style10
    {
        height: 43px;
    }
    </style> 
<div align="center">

<asp:UpdatePanel id="update1" runat="Server">
<ContentTemplate>

    <table style="border-style: solid; border-width: thin; border-color: #808080; padding: 3px; margin: 0px; width: 723px;" 
        cellpadding="5" cellspacing="5">
        <tr>
            <td bgcolor="#7D7D7D" align="center" class="style8" 
                style="border-style: solid; border-width: thin">
                <asp:Label ID="lblDanhSachTinNhan" runat="server" Font-Bold="True" 
                    Font-Size="Large" ForeColor="White"
                    Text="Danh Sách Tin Nhắn"></asp:Label>
            </td>
        </tr>
        <tr bgcolor="#6500CA">
            <td align="left" class="style10" 
                style="border-style: solid; border-width: thin">
                <asp:Button runat="server" Text="Trả Lời" ID="btnTraLoi" Height="24px" 
                    Width="86px" onclick="btnTraLoi_Click"/>                        
                <asp:Button runat="server" Text="Xóa" ID="btnXoa" Height="24px" Width="80px" 
                    style="margin-left: 20px" onclick="btnXoa_Click1" />            
                <asp:DropDownList ID="ddlSapXep" runat="server" Height="24px" 
                    style="margin-top: 3px; margin-left: 20px;" AutoPostBack="True" 
                    onselectedindexchanged="ddlSapXep_SelectedIndexChanged">
                    <asp:ListItem>Sắp xếp...</asp:ListItem>
                    <asp:ListItem>Tên Người Gửi</asp:ListItem>
                    <asp:ListItem>Ngày Gửi</asp:ListItem>
                </asp:DropDownList>                        
                <asp:DropDownList ID="ddlTangGiam" runat="server" Height="24px" 
                    style="margin-top: 3px; margin-left: 10px;" AutoPostBack="True" 
                    onselectedindexchanged="ddlSapXep_SelectedIndexChanged">
                    <asp:ListItem>Tăng Dần</asp:ListItem>
                    <asp:ListItem>Giảm Dần</asp:ListItem>
                </asp:DropDownList>
                
                <asp:HyperLink runat="Server" NavigateUrl="~/Message/GuiTinNhan.aspx" Height="24px" 
                    style="margin-top: 3px; margin-left: 10px;">
                    <asp:Button ID="Button1" runat="server"  Text="Gửi tin nhắn" />
                    </asp:HyperLink>
            </td>  
            
                
                                                            
        </tr>        
        <tr>
            <td style="border-style: solid; border-width: thin" align="center" 
                bgcolor="#CCCCCC" colspan="4">                
                <asp:Label ID="lblTrangThai" runat="server" Text=""></asp:Label>
            </td>
            <tr>
                <td style="border-style: solid; border-width: thin">
                    <asp:GridView ID="gridTinNhan" runat="server" AllowPaging="True" 
                        AllowSorting="True" AutoGenerateColumns="False" BackColor="White" 
                        BorderColor="White" BorderStyle="Ridge" BorderWidth="2px" CellPadding="3" 
                        CellSpacing="1" DataKeyNames="MaTinNhan" GridLines="None" 
                        style="margin-right: 4px" Width="100%" 
                        onpageindexchanging="gridTinNhan_PageIndexChanging">
                        <RowStyle BackColor="#DEDFDE" ForeColor="Black" />
                        <Columns>
                            <asp:TemplateField>
                                <HeaderTemplate>
                                    <HeaderTemplate>
                                        <input id="chkAll" runat="server" 
                                            onclick="javascript:SelectAllCheckboxes(this);" type="checkbox" />
                                    </HeaderTemplate>
                                </HeaderTemplate>
                                <ItemTemplate>
                                    <asp:CheckBox ID="chkCheckItem" runat="server" 
                                        oncheckedchanged="chkCheckItem_CheckedChanged" />
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:BoundField DataField="MaTinNhan" Visible="False" />
                            <asp:BoundField DataField="NguoiGui" HeaderText="Người Gửi" />
                            <asp:HyperLinkField DataNavigateUrlFields="MaTinNhan" 
                                DataNavigateUrlFormatString="~/Message/ChiTietTinNhan.aspx?MaTinNhan={0}" 
                                DataTextField="TieuDeTinNhan" HeaderText="Tiêu Đề Tin Nhắn" />
                            <asp:BoundField DataField="ThoiGianNhanTin" HeaderText="Thời Gian Nhận Tin" />
                            <asp:BoundField DataField="Readed" HeaderText="Đã Đọc" />
                        </Columns>
                        <FooterStyle BackColor="#C6C3C6" ForeColor="Black" />
                        <PagerStyle BackColor="#C6C3C6" ForeColor="Black" HorizontalAlign="Right" />
                        <SelectedRowStyle BackColor="#9471DE" Font-Bold="True" ForeColor="White" />
                        <HeaderStyle BackColor="#4A3C8C" Font-Bold="True" ForeColor="#E7E7FF" />
                        <AlternatingRowStyle BorderColor="#CCFFFF" BorderStyle="Ridge" />
                    </asp:GridView>
                </td>
            </tr>
        </tr>
    </table>
</div>
</ContentTemplate>
</asp:UpdatePanel>

<script language="javascript">

 function SelectAllCheckboxes(spanChk){

   // Added as ASPX uses SPAN for checkbox

   var oItem = spanChk.children;
   var theBox= (spanChk.type=="checkbox") ? 
        spanChk : spanChk.children.item[0];
   xState=theBox.checked;
   elm=theBox.form.elements;

   for(i=0;i<elm.length;i++)
     if(elm[i].type=="checkbox" && 
              elm[i].id!=theBox.id)
     {
       //elm[i].click();

       if(elm[i].checked!=xState)
         elm[i].click();
       //elm[i].checked=xState;

     }
 }
</script>